#include <my_head.h>

int main(int argc, const char *argv[]){
    int fd = 0;
    if(-1 == (fd = open("hello.txt", O_RDONLY)))
        ERR_LOG("open error");
    char buff[5] = {0};
    int ret = 0;
    ret = read(fd, buff, 4);
    printf("ret = [%d]  buff = [%s]\n", ret, buff); // 4 abcd
    ret = read(fd, buff, 4);
    printf("ret = [%d]  buff = [%s]\n", ret, buff); // 4 efg\n
    ret = read(fd, buff, 4);
    printf("ret = [%d]  buff = [%s]\n", ret, buff); // 4 12\nx
    // 这一次读到内容了 虽然没有读够文件结束了 但返回值也是实际读到的字节数
    ret = read(fd, buff, 4);
    printf("ret = [%d]  buff = [%s]\n", ret, buff); // 2 yz
    // 再读 返回值才是0
    ret = read(fd, buff, 4);
    printf("ret = [%d]  buff = [%s]\n", ret, buff); // 0
    close(fd);
    return 0;
}